package com.hc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.domain.DictType;
import com.hc.dto.ListDictTypeDTO;
import com.hc.mapper.DictTypeMapper;
import com.hc.service.DictTypeService;
import com.hc.vo.DictTypeVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典类型
 *
 * @author 梁云亮
 */
@Service
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {

    @Resource
    private DictTypeMapper dictTypeMapper;

    @Override
    public int createDictType(DictTypeVO dictTypeVO) {
        int res = dictTypeMapper.insertDictType(dictTypeVO);
        return res;
    }

    @Override
    public int deleteDictTypeById(Integer id) {
        int res = dictTypeMapper.deleteDictTypeById(id);
        return res;
    }

    @Override
    public boolean getDictTypeByName(String name) {
        boolean res = dictTypeMapper.selectDictTypeByName(name) == 1 ? true : false;
        return res;
    }

    @Override
    public List<ListDictTypeDTO> listDictTypeByParentName(String name) {
        List<ListDictTypeDTO> res = dictTypeMapper.selectDictTypeByParentName(name);
        return res;
    }
}
